<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->string('no');

            $table->decimal('price',10,0)->default(0);
            $table->decimal('freight',10,0)->default(0);
            $table->decimal('product_price',10,0)->default(0);

            $table->tinyInteger('delivery_type')->default(0);
            $table->string('express_no')->nullable();

            $table->string('name')->nullable();
            $table->string('phone')->nullable();
            $table->string('email')->nullable();
            $table->string('line_id')->nullable();
            $table->string('city')->nullable();
            $table->string('county')->nullable();
            $table->string('street')->nullable();
            $table->string('address')->nullable();
            $table->string('shop_no')->nullable();
            $table->string('shop_name')->nullable();

            $table->text('remarks')->nullable();
            $table->text('admin_remarks')->nullable();
            $table->ipAddress('ip')->nullable();
            $table->string('ipcountry')->nullable();
            $table->text('user_agent')->nullable();
            $table->timestamp('ship_at')->nullable();
            $table->timestamp('sign_at')->nullable();
            $table->timestamp('settle_at')->nullable();
            $table->tinyInteger('status')->default(0);
            $table->tinyInteger('is_confirm')->default(0);
            $table->tinyInteger('is_settle')->default(0);

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
